<template>
<div>
  姓名：<input type="text" v-model="name"><br>
  年龄：<input type="text" v-model="age"><br>
  身高：<input type="text" v-model="height">(米)<br>
  体重：<input type="text" v-model="weight">(千克)<br>
  病史：<input type="text" v-model="disease"><br>
  <button @click="judge">诊断</button><br>
  <p v-if=flag>患者：{{ name }} 的诊断结果为：{{ result }}</p>
</div>
</template>

<script>
export default {
 data() {
  return {
    name: '',
    age: '',
    height: '',
    weight: '',
    disease: '',
    result: '',
    flag: false
  }
 },
 methods: {
  judge() {
    let bmi = this.weight / (this.height * this.height)
    console.log(bmi)
    if(bmi <= 18.5) {
      this.result = '体重过轻'
    }
    if( bmi > 18.5 && bmi <= 24.9) {
      this.result = '正常'
    }
    if(bmi > 24.9 && bmi <= 29.9) {
      this.result = '体重过重'
    }
    if(bmi > 29.9) {
      this.result = '肥胖'
    }
    if(!this.flag) {
      this.flag = !this.flag
    }
  }
 }
}
</script>